package baidu.dao;

import baidu.pojo.IDCardDistinguish;
import baidu.pojo.form.IDCardDistinguishAddForm;
import common.spring.jdbc.MySQLHelper;
import common.utils.MyMapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created by asus on 2018/12/21.
 */
@Repository
public class IDCardDistinguishDao {

    @Autowired
    MySQLHelper mySQLHelper;

    public int addIDCardDistinguish(IDCardDistinguishAddForm form){
        return mySQLHelper.simpleInsert("idCard_authentication", MyMapUtils.beanToMap(form,false));
    }

    public IDCardDistinguish getIDCardDistinguish(String openId){
        return mySQLHelper.queryForBean("select * from idCard_authentication where openId=? limit 1",IDCardDistinguish.class,new Object[]{openId});
    }

    public IDCardDistinguish getIDCardDistinguishName(String openId,String realName){
        return mySQLHelper.queryForBean("select * from idCard_authentication where openId=? and name=? limit 1",IDCardDistinguish.class,new Object[]{openId,realName});
    }

    public Long getIDCardDistinguishNum(String openId){
        return mySQLHelper.queryForNumber("select count(1) from idCard_authentication where openId=?",new Object[]{openId});
    }
}
